package com.woniuxy;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: 马宇航
 * @Do: 订单服务，服务消费者，消费商品
 * @DateTime: 22/06/21/0021 下午 3:14
 * @Component: 成都蜗牛学苑
 **/
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients //开启Feign客户端
//@EnableCircuitBreaker //开启熔断器
@EnableHystrix //使用Hystrix组件，来完成熔断
public class OrderApp {
    public static void main(String[] args) {
        SpringApplication.run(OrderApp.class,args);
    }
    @Bean
    @LoadBalanced //开启默认的负载均衡策略
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    @Bean
    public IRule randomRule(){
        return new RoundRobinRule();
    }
}
